package wondersgroup.hsswidget.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import wondersgroup.hsswidget.R;

/**
 * @author 黄赛赛
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}()
 * @date 2016/10/19 14:54
 */
public class SimpleRecycleAdapter extends RecyclerView.Adapter <SimpleRecycleAdapter.MyViewHodler>{
    Context mCotext;
    List<String > list;

    public SimpleRecycleAdapter(Context mCotext) {
        this.mCotext = mCotext;
    }

    @Override
    public MyViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHodler holder = new MyViewHodler(LayoutInflater.from(mCotext
                ).inflate(R.layout.adapter_card_text, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHodler holder, int position) {
        holder.tv_name.setText(list.get(position));
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    class MyViewHodler extends RecyclerView.ViewHolder{
        TextView tv_name;

        public MyViewHodler(View itemView) {
            super(itemView);
            tv_name = (TextView) itemView.findViewById(R.id.tv_name);
        }
    }
}
